package main.java.thread;

public class Bank {
    private int account = 20000;
    public synchronized boolean getMoney(int money){
       int account = getAccount();
       if(money<=account){
           account = account - money;
           Thread.yield();
           setAccount(account);
           return true;
       }
       return false;
    }
    public int getAccount(){
        return account;
    }
    public void setAccount(int account){
        this.account = account;
    }
}
